package com.wlc.base.design.strategymode.v2;

/**
 * @author 王立朝
 * @date 2022/3/16
 * @description: 打折收费
 */
public class CashReturn extends CashSuper {

    /**
     * 返利条件，例如：满300 返100 则moneyCondition = 300
     * moneyReturn = 100
     */
    private double moneyCondition = 0.0d;
    /**
     * 返利
     */
    private double moneyReturn = 0.0d;

    public CashReturn(double moneyCondition, double moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    /**
     * 接受现金的抽象方法
     *
     * @param money
     * @return
     */
    @Override
    public double acceptCash(Double money) {
        double result = money;
        if(result>moneyCondition){
            result = money - Math.floor(money/moneyCondition)*moneyReturn;
        }
        return result;
    }
}
